import { http } from "@/utils/http";
import type { HttpResponse } from "types/request";

import { URL_PREFIX } from "@/api/constants";

export type VersionResponse = {
  module?: string;
  version?: string;
  env?: string;
  app_name?: string;
  extra?: {
    common_env?: string;
    mysql?: {
      host?: string;
      port?: number;
      user?: string;
    };
    git?: {
      commit?: string;
      branch?: string;
    };
  };
};

export const getVersion = () => {
  return http.request<HttpResponse<VersionResponse>>(
    "get",
    `${URL_PREFIX}/sysinfo/version`
  );
};
